Bug 530575 – GtkEntry with invisible chars has a confused cursor in
authorMatthias Clasen <mclasen@redhat.com>
Fri, 3 Oct 2008 01:16:48 +0000 (01:16 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 3 Oct 2008 01:16:48 +0000 (01:16 +0000)
2008-10-02  Matthias Clasen <mclasen@redhat.com>

        Bug 530575 – GtkEntry with invisible chars has a confused cursor in
        overwrite mode

        * gtk/gtkentry.c (gtk_entry_draw_cursor): Use the visible text
        in the layout when positioning the cursor, not the actual text
        content of the entry. This makes a different when using overwrite
        mode in an invisible entry.
        Problem noticed by Jonathan Blandford

        * gtk/gtktextutil.c: Fix a typo in a comment

svn path=/trunk/; revision=21580

ChangeLog
gtk/gtkentry.c
gtk/gtktextutil.c

index a08af25ee822fa02668eae058f37a5321ee1aa1e..1db7dd605dd327caf10e262e1986e69bb6efec88 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-10-02  Matthias Clasen <mclasen@redhat.com>
+
+       Bug 530575 – GtkEntry with invisible chars has a confused cursor in
+       overwrite mode
+
+       * gtk/gtkentry.c (gtk_entry_draw_cursor): Use the visible text
+       in the layout when positioning the cursor, not the actual text
+       content of the entry. This makes a different when using overwrite
+       mode in an invisible entry. 
+       Problem noticed by Jonathan Blandford
+
+       * gtk/gtktextutil.c: Fix a typo in a comment
+
 2008-10-02  Christian Persch
 
         Bug 554704 – gtkfilesystemmodel does too much work
        Bug 552959 – GtkTrayIcon: _NET_SYSTEM_TRAY_VISUAL and real
        transparency
 
-       * gtk/gtktrayicon-x11.c: Add support for the _BET_SYSTEM_TRAY_VISUAL
+       * gtk/gtktrayicon-x11.c: Add support for the _NET_SYSTEM_TRAY_VISUAL
        property described in
        http://lists.freedesktop.org/archives/xdg/2008-September/009919.html
        If _NET_SYSTEM_TRAY_VISUAL is a visual with an alpha channel, the 
index 3bcf0e087e1fe8fa3c9457be3bef4cfb44d465ed..cf510a318d05b855b355286c91e320e4ff3cca9b 100644 (file)
@@ -3794,6 +3794,8 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
       gint cursor_index;
       gboolean block;
       gboolean block_at_line_end;
+      PangoLayout *layout;
+      const char *text;
 
       _gtk_entry_effective_inner_border (entry, &inner_border);
 
@@ -3801,11 +3803,13 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
 
       gdk_drawable_get_size (entry->text_area, NULL, &text_area_height);
 
-      cursor_index = g_utf8_offset_to_pointer (entry->text, entry->current_pos + entry->preedit_cursor) - entry->text;
+      layout = gtk_entry_ensure_layout (entry, TRUE);
+      text = pango_layout_get_text (layout);
+      cursor_index = g_utf8_offset_to_pointer (text, entry->current_pos + entry->preedit_cursor) - text;
       if (!entry->overwrite_mode)
         block = FALSE;
       else
-        block = _gtk_text_util_get_block_cursor_location (gtk_entry_ensure_layout (entry, TRUE),
+        block = _gtk_text_util_get_block_cursor_location (layout,
                                                           cursor_index, &cursor_rect, &block_at_line_end);
 
       if (!block)
@@ -3861,7 +3865,6 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
         }
       else /* overwrite_mode */
         {
-          PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
           GdkColor cursor_color;
           GdkRectangle rect;
           cairo_t *cr;
index dc05880d41d07498b2bade8a59947c49a995bfed..145ef2b5fe17047d7cda24029d3fc4e220425f8d 100644 (file)
@@ -406,7 +406,7 @@ layout_get_char_width (PangoLayout *layout)
  * @layout: a #PangoLayout
  * @index: index at which cursor is located
  * @pos: cursor location
- * @at_line_end: whether cursor i sdrawn at line end, not over some
+ * @at_line_end: whether cursor idrawn at line end, not over some
  * character
  *
  * Returns: whether cursor should actually be drawn as a rectangle.